//
//  WBNagationController.swift
//  swiftweibo
//
//  Created by ffxk007 on 2017/6/1.
//  Copyright © 2017年 ffxk007. All rights reserved.
//

import UIKit

class WBNagationController: UINavigationController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        navigationBar.isHidden = true
    }

    override func pushViewController(_ viewController: UIViewController, animated: Bool) {
//        print(viewController)
        
        if childViewControllers.count > 0 {
            viewController.hidesBottomBarWhenPushed = true
            if let vc = viewController as? WBBaseViewController {
                
                var title = "返回"
                if childViewControllers.count == 1 {
                    title = childViewControllers.first?.title ?? "返回"
                }
                
                vc.navItem.leftBarButtonItem = UIBarButtonItem(title: title, target: self, action: #selector(popTParent),isBackButton:true)
            }

        }
        
        super.pushViewController(viewController, animated: true)
    }
    
    @objc fileprivate func popTParent() {
        popViewController(animated: true)
    }
}
